<?php
error_reporting(E_ERROR);
?>

<?php
function curl_get($durl) {
  $t = parse_url($durl);
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$durl);
  curl_setopt($ch, CURLOPT_HEADER, false);  
  curl_setopt($ch, CURLOPT_TIMEOUT,5);
  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 // curl_setopt($ch, CURLOPT_RANGE, 1-100);
  $r = curl_exec($ch);
  curl_close($ch);
  return $r;
}
?>

<?php
function curl_get_montior_type ($Machine_sn) {

//$page = curl_get( 'http://support1.lenovo.com.cn/lenovo/wsi/usercenter/computersearch/StandardMyComputerSearch.aspx?id=WS70087123');
$page = curl_get( 'http://support1.lenovo.com.cn/lenovo/wsi/usercenter/computersearch/StandardMyComputerSearch.aspx?id='.$Machine_sn);

$start = strstr($page,"litMachineName_LK");
$start_n1 = strpos($start,"span");

$start_n2 = strpos($start,"lblPartEndDate_LK");

$start_n3 = strpos($start,"lblOnSiteEndDate_LK");

//echo $start_n."****";

$result = substr($start,40,($start_n3+20));

//$result = substr($start,0,($start_n+100));

 //$lines_string=implode('',$arr);
 
 
 $result = str_replace("+"," ",$result);
 return urldecode($result);
//echo $result;
}

?>

<?php
echo curl_get_montior_type($_REQUEST['sn'])
?>
